<?php
declare(strict_types=1);

use Phinx\Migration\AbstractMigration;

final class CreateTaskWorkOrderUser extends AbstractMigration
{
    public function up()
    {
        $table = $this->table('task_work_order_user', ['id' => false, 'primary_key' => ['id'], 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '工单人员表']);
        $table->addColumn('id', 'integer', ['identity' => true, 'signed' => false, 'limit' => 11, 'comment' => '主键ID'])
            ->addColumn('work_order_id', 'integer', ['signed' => false, 'default' => 0, 'limit' => 11, 'comment' => '工单ID'])
            ->addColumn('user_id', 'integer', ['signed' => false, 'default' => 0, 'limit' => 11, 'comment' => '工单人员ID'])
            ->addColumn('message_unread', 'enum', ['values' => 'yes,no', 'default' => 'no', 'null' => false, 'comment' => '是否有未读消息'])
            ->addColumn('created', 'integer', ['null' => false, 'default' => 0, 'limit' => 11, 'signed' => false, 'comment' => '创建时间'])
            ->save();
        $table->addIndex('work_order_id', ['name' => 'work_order_id_index', 'type' => 'normal']);
        $table->save();
    }

    public function down()
    {
        $this->table('task_work_order_user')->drop()->save();
    }
}
